define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'grhtml', 'CreateControl'], function ($, undefined, Backend, Table, Form) {

    var Controller = {
        _queryString: '',
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'tvsd/pc/index' + Controller._queryString,
                    add_url: 'tvsd/pc/add' + Controller._queryString,
                    edit_url: 'tvsd/pc/edit',
                    cjxg_url: 'tvsd/pc/cjxg',
                    del_url: 'tvsd/pc/del',
                    dy_url: 'tvsd/pc/dy',
                    multi_url: 'tvsd/pc/multi',
                    import_url: 'tvsd/pc/import',
                    table: 'dd_pc',
                }
            });


            var table = $("#table");
            table.on('post-common-search.bs.table', function (event, table) {
                //欲要跳转TAB的值
                $('ul.nav-tabs li a[data-value="预定"]').trigger('click');
                //TAB分类的字段
                $('.form-commonsearch select[name=status]').val("预定");
            })
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'weigh',
                fixedColumns: true,

                fixedRightNumber: 1,
                exportTypes: ['excel'],//导出只显示
                exportOptions: {
                    fileName: '车辆调派单报表_' + Moment().format("YYYY-MM-DD"),
                    ignoreColumn: [0, 'checkbox', 'operate'], //默认不导出第一列(checkbox)与操作(operate)列
                    mso: {
                        // fileFormat:        'xlsx',
                        //修复导出数字不显示为科学计数法
                        onMsoNumberFormat: function (cell, row, col) {
                            return !isNaN($(cell).text()) ? '\\@' : '';
                        }
                    }

                },
                columns: [
                    [
                        { checkbox: true },
                        {
                            field: '', title: __('序号'), formatter: function (value, row, index) {
                                var options = table.bootstrapTable('getOptions');
                                var pageNumber = options.pageNumber;

                                var pageSize = options.pageSize == "All" ? 100000 : options.pageSize;

                                return (pageNumber - 1) * pageSize + 1 + index;
                            }, operate: false
                        },
                        // { field: 'id', title: __('Id') },
                        {
                            field: 'ddh', title: __('Ddh'), operate: 'LIKE', formatter: function (value, row, index) {
                                if (row.status == '确定') {
                                    return '<b style = "color:#00CD66">' + value + '</b>'
                                } else {
                                    return '<b style = "color:#FFB90F">' + value + '</b>'
                                }
                            }
                        },
                        { field: 'kh', title: __('Kh'), sortable: true, operate: 'LIKE' },
                        { field: 'cp', title: __('Cp'), sortable: true, operate: 'LIKE' },
                        { field: 'kstime', title: __('Kstime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
                        { field: 'jstime', title: __('Jstime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', autocomplete: false },
                        { field: 'lxr', title: __('Lxr'), sortable: true, operate: 'LIKE' },
                        { field: 'dh', title: __('Dh'), operate: 'LIKE' },
                        { field: 'cd', title: __('Cd'), sortable: true, operate: 'LIKE' },
                        { field: 'zws', title: __('Zws'), sortable: true, operate: false },
                        { field: 'jsy1', title: __('Jsy1'), sortable: true, operate: 'LIKE' },
                        // {field: 'jsydh1', title: __('Jsydh1'), operate: 'LIKE'},
                        { field: 'jsy2', title: __('Jsy2'), sortable: true, operate: 'LIKE' },
                        // {field: 'jsydh2', title: __('Jsydh2'), operate: 'LIKE'},
                        { field: 'scd', title: __('Scd'), sortable: true, operate: 'LIKE' },
                        { field: 'tj', title: __('Tj'), sortable: true, operate: false },
                        { field: 'mdd', title: __('Mdd'), sortable: true, operate: 'LIKE' },
                        { field: 'je', title: __('Je'), sortable: true },
                        { field: 'fs', title: __('Fs'), searchList: { "现金": __('现金'), "转账": __('转账'), "其他": __('其他') }, formatter: Table.api.formatter.status },
                        { field: 'bz', title: __('Bz'), operate: false },
                        { field: 'status1', title: __('Status1'), searchList: { "未报销": __('未报销'), "已报销": __('已报销') }, formatter: Table.api.formatter.status },
                        { field: 'status', title: __('Status'), searchList: { "预定": __('预定'), "确定": __('确定') }, formatter: Table.api.formatter.status },
                        { field: 'ddr', title: __('Ddr'), operate: 'LIKE' },
                        // {field: 'admin_id', title: __('Admin_id')},
                        // { field: 'weigh', title: __('Weigh'), operate: false },
                        { field: 'createtime', title: __('Createtime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        { field: 'updatetime', title: __('Updatetime'), sortable: true, operate: 'RANGE', addclass: 'datetimerange', autocomplete: false, formatter: Table.api.formatter.datetime },
                        // { field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate },
                        {
                            field: 'buttons',
                            // width: "120px",
                            title: __('操作'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    //编辑页面显示按钮
                                    name: 'edit',
                                    text: __('编辑'),
                                    title: __('编辑'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-pencil',
                                    url: 'tvsd/pc/edit',
                                    visible: function (row) {
                                        if (row.status1 == '已报销' || row.status == '确定') {
                                            return false;//按钮不显示
                                        } else {
                                            return true;//按钮显示
                                        }

                                    },
                                },
                                {
                                    name: 'dy',
                                    text: __('打印'),
                                    title: __('打印'),
                                    classname: 'btn btn-xs btn-success btn-dialog',
                                    icon: 'fa fa-print',
                                    url: 'tvsd/pc/dy?ids={ids}',
                                    // click: [$.cookie('ids', {ids})],
                                },
                                {
                                    //报销页面显示按钮
                                    name: 'bx',
                                    text: __('报销'),
                                    title: __('报销'),
                                    classname: 'btn btn-xs btn-primary btn-dialog',
                                    icon: 'fa fa-calculator',
                                    url: 'tvsd/bx/add?ids={ids}&dh={ddh}',

                                    visible: function (row) {
                                        if (row.status1 == '已报销' || row.status == '预定') {
                                            return false;//按钮不显示
                                        } else {
                                            return true;//按钮显示
                                        }

                                    },
                                },
                                {
                                    //删除按钮
                                    name: 'del',
                                    text: __('删除'),
                                    title: __('删除'),
                                    classname: 'btn btn-xs btn-danger btn-ajax',
                                    icon: 'fa fa-trash',
                                    url: 'tvsd/pc/del',
                                    confirm: function (row) {
                                        return '调派单号：' + row.ddh + ' 确定要删除';
                                    },
                                    visible: function (row) {
                                        if (row.status1 == '已报销' || row.status == '确定') {
                                            return false;//按钮不显示
                                        } else {
                                            return true;//按钮显示
                                        }
                                    },
                                    refresh: true,
                                }, {
                                    //编辑页面显示按钮
                                    name: 'cjxg',
                                    text: __('超级编辑'),
                                    title: __('超级编辑'),
                                    classname: 'btn btn-xs btn-danger btn-dialog',
                                    icon: 'fa fa-pencil',
                                    url: 'tvsd/pc/cjxg',
                                    visible: function (row) {
                                        if (row.status == '预定') {
                                            return false;//按钮不显示
                                        } else {
                                            return true;//按钮显示
                                        }

                                    },

                                }

                            ],
                            formatter: Table.api.formatter.buttons
                        }



                    ]
                ]
            });

            Table.api.bindevent(table);
        },
        recyclebin: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    'dragsort_url': ''
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: 'tvsd/pc/recyclebin' + location.search,
                pk: 'id',
                sortName: 'id',
                columns: [
                    [
                        { checkbox: true },
                        { field: 'id', title: __('Id') },
                        {
                            field: 'deletetime',
                            title: __('Deletetime'),
                            operate: 'RANGE',
                            addclass: 'datetimerange',
                            formatter: Table.api.formatter.datetime
                        },
                        {
                            field: 'operate',
                            width: '140px',
                            title: __('Operate'),
                            table: table,
                            events: Table.api.events.operate,
                            buttons: [
                                {
                                    name: 'Restore',
                                    text: __('Restore'),
                                    classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
                                    icon: 'fa fa-rotate-left',
                                    url: 'tvsd/pc/restore',
                                    refresh: true
                                },
                                {
                                    name: 'Destroy',
                                    text: __('Destroy'),
                                    classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
                                    icon: 'fa fa-times',
                                    url: 'tvsd/pc/destroy',
                                    refresh: true
                                }
                            ],
                            formatter: Table.api.formatter.operate
                        }
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        //派车记录表格按月展示
        pcjl: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    lypc_url: 'tvsd/pc/pcjl',
                    add_url: 'tvsd/pc/add' + Controller._queryString,
                    table: 'pcjl',
                }
            });

            var table = $("#table");
            var bjys = "rgb(24,188,156);border: 2px solid black";//背景颜色
            var bjys1 = "rgb(255,255,0);border: 2px solid black";//背景颜色
            var bk = "border: 2px solid black;";//边框颜色
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.lypc_url,
                // pk: 'category_names',
                pk: 'cp',
                search: false,//快速搜索
                showToggle: false,//浏览模式可以切换卡片视图和表格视图两种模式
                showColumns: false,//显示隐藏列可以快速切换字段列的显示和隐藏
                pagination: false,//不显示分页
                striped: true,//设置为 true 会有隔行变色效果
                escape: false,//转义HTML字符串
                fixedColumns: true,//	是否启用固定列功能
                fixedNumber: 2,//左侧固定列的数量
                searchFormVisible: true,//显示高级搜索表单
                dblClickToEdit: false,//双击不触发编辑功能
                undefinedText: '-',//当数据为 undefined 时显示的字符。
                classes: 'table table-hover',//表格的类名称。默认情况下，表格是有边框的，你可以添加 'table-no-bordered' 来删除表格的边框样式。
                exportTypes: ['excel'],//导出只显示
                exportOptions: {
                    fileName: '车辆调派月报表记录_' + Moment().format("YYYY-MM-DD"),
                    ignoreColumn: [0, 'checkbox', 'operate'], //默认不导出第一列(checkbox)与操作(operate)列

                },
                columns: [
                    [
                        // {checkbox: true,visible:false},
                        // {field: 'id', title: __('Id')},
                        {
                            field: 'xl', title: __('线路'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 'cp', title: __('车牌'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 'zws', title: __('座位数'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's1', title: __('1日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s1']) {

                                    if (row['status1'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                } else {
                                    return { css: { "border": "2px solid black" } };
                                }

                            }

                        },
                        {
                            field: 's2', title: __('2日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s2']) {
                                    if (row['status2'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's3', title: __('3日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s3']) {
                                    if (row['status3'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's4', title: __('4日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s4']) {
                                    if (row['status4'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's5', title: __('5日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s5']) {
                                    if (row['status5'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's6', title: __('6日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s6']) {
                                    if (row['status6'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's7', title: __('7日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s7']) {
                                    if (row['status7'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's8', title: __('8日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s8']) {
                                    if (row['status8'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's9', title: __('9日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s9']) {
                                    if (row['status9'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's10', title: __('10日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s10']) {
                                    if (row['status10'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's11', title: __('11日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s11']) {
                                    if (row['status11'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's12', title: __('12日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s12']) {
                                    if (row['status12'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's13', title: __('13日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s13']) {
                                    if (row['status13'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's14', title: __('14日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s14']) {
                                    if (row['status14'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's15', title: __('15日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s15']) {
                                    if (row['status15'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's16', title: __('16日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s16']) {
                                    if (row['status16'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's17', title: __('17日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s17']) {
                                    if (row['status17'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's18', title: __('18日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s18']) {
                                    if (row['status18'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's19', title: __('19日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s19']) {
                                    if (row['status19'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's20', title: __('20日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s20']) {
                                    if (row['status20'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's21', title: __('21日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s21']) {
                                    if (row['status21'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's22', title: __('22日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s22']) {
                                    if (row['status22'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's23', title: __('23日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s23']) {
                                    if (row['status23'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's24', title: __('24日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s24']) {
                                    if (row['status24'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's25', title: __('25日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s25']) {
                                    if (row['status25'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's26', title: __('26日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s26']) {
                                    if (row['status26'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's27', title: __('27日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s27']) {
                                    if (row['status27'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's28', title: __('28日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s28']) {
                                    if (row['status28'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's29', title: __('29日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s29']) {
                                    if (row['status29'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's30', title: __('30日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s30']) {
                                    if (row['status30'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 's31', title: __('31日'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                // console.log(row);//undefined
                                if (row['s31']) {
                                    if (row['status31'] == '确定') {
                                        return { css: { "background-color": bjys } };
                                    } else {
                                        return { css: { "background-color": bjys1 } };
                                    }
                                }
                                return { css: { "border": "2px solid black" } };
                            }
                        },
                        {
                            field: 'ts', title: __('趟数'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                return { css: { "border": "2px solid black" } };
                            }

                        },
                        {
                            field: 'byts', title: __('本月天数'), operate: false, align: 'center', cellStyle: function (value, row, index) {
                                return { css: { "border": "2px solid black" } };
                            }

                        },
                        { field: 'cd', title: __('按车队分组'), operate: '=', addclass: 'selectpage', data: 'data-source="tvsd/cd/index"  data-primary-key="name"  data-order-by="weigh asc" data-select-only="true"', visible: false },
                        { field: 'pctime', title: __('派车按月查询'), formatter: Table.api.formatter.datetime, addclass: 'datetimepicker', data: 'data-date-format="YYYY-MM-DD"', operate: '=', visible: false },

                    ]
                ],
                onLoadSuccess: function (data) {
                    //数据加载成功后 进行合并
                    // mergeTable(data, "table");
                    // console.log(data.rows.length);
                    // table.bootstrapTable('mergeCells', { index: 1, field: 's1', colspan: 3, rowspan: 1 });
                    for (var i = 0; i < data.rows.length; i++) {
                        for (var j = 1; j < 31; j++) {
                            if (data.rows[i]['colspan' + j]) {
                                table.bootstrapTable('mergeCells', { index: i, field: 's' + j, colspan: data.rows[i]['colspan' + j] });
                                // console.log(data.rows[i]['cp'],data.rows[i]['s'+j],data.rows[i]['colspan'+j],i,j);
                            }
                        }
                    }
                },
                onDblClickCell: function (field, value, row, $element) {
                    // console.log(field, value, row);
                    layer.open({
                        content: '确定修改此订单？？？',
                        // time:2000,
                        btn: ['确定', '取消'],
                        yes: function (index, layero) {
                            // console.log(index);
                            layer.close(index);//关闭提示
                            Fast.api.open("/xgx.php/tvsd/pc/edit/ids/" + row['id' + field], '临时修改订单', '');

                        },

                    });
                },

            });


            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        //打印页面
        dy: function () {

            //取网址 ？ 后面的ids

            var ids = getUrlParam('ids');
            // //html5 方式打开报表
            // $(document).ready(function () {
            //     //创建报表显示器，参数指定其在网页中的占位标签的ID，关联的报表模板URL，关联的报表数据URL 
            //     // console.log(ids);
            //     var reportViewer = window.rubylong.grhtml5.insertReportViewer("report_holder", 
            //     "/static/派车调度单.grf", "dysj?ids="+ ids);
            //     //启动报表运行，生成报表 

            //     reportViewer.start();
            // });

            //插件方式打开报表
            $(document).ready(function () {
                InsertPrintViewer({
                    //取网页传参，取？后面部分包括？

                    report: urlAddRandomNo("/static/派车调度单.grf"),
                    data: 'dysj?ids=' + ids
                });
            });

        },
        add: function () {
            //页面加载完成，添加订单号
            $(document).ready(function () {
                $('#c-ddh').val(createordernum());
            });
            //开始日期变化，改变结束日期
            $("#c-kstime").on('dp.change', function () {
                $('#c-jstime').val($('#c-kstime').val());
            });
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        cjxg: function () {//超级修改编辑
            Controller.api.bindevent();
        },
        jrpc: function () {//今日派车记录查询
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    jrpc_url: 'tvsd/pc/jrpc',
                    table: 'jrpc',
                }
            });

            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.jrpc_url,
                // pk: 'category_names',
                pk: 'cp',
                search: false,//快速搜索
                showToggle: false,//浏览模式可以切换卡片视图和表格视图两种模式
                showColumns: false,//显示隐藏列可以快速切换字段列的显示和隐藏
                pagination: false,//不显示分页
                commonSearch: false,//是否启用高级搜索
                searchFormVisible: false,//显示高级搜索表单
                undefinedText: '-',//当数据为 undefined 时显示的字符
                striped: true,//隔行变色
                exportTypes: ['excel'],//导出只显示
                exportOptions: {
                    fileName: '今日调派车辆_' + Moment().format("YYYY-MM-DD"),
                    ignoreColumn: [0, 'checkbox', 'operate'] //默认不导出第一列(checkbox)与操作(operate)列
                },
                columns: [
                    [
                        // {checkbox: true,visible:false},
                        // {field: 'id', title: __('Id')},
                        {
                            field: '', title: __('序号'), formatter: function (value, row, index) {
                                var options = table.bootstrapTable('getOptions');
                                var pageNumber = options.pageNumber;

                                var pageSize = options.pageSize == "All" ? 100000 : options.pageSize;

                                return (pageNumber - 1) * pageSize + 1 + index;
                            }, operate: false
                        },
                        { field: 'cd', title: __('Cd'), sortable: true, operate: false, align: 'center' },
                        { field: 'cp', title: __('Cp'), sortable: true, operate: false, align: 'center' },
                        { field: 'kstime', title: __('Kstime'), sortable: true, operate: false, addclass: 'datetimerange', autocomplete: false },
                        { field: 'jstime', title: __('Jstime'), sortable: true, operate: false, addclass: 'datetimerange', autocomplete: false },
                        { field: 'scd', title: __('Scd'), sortable: true, operate: false },
                        { field: 'tj', title: __('Tj'), sortable: true, operate: false },
                        { field: 'mdd', title: __('Mdd'), sortable: true, operate: false },
                        { field: 'jsy1', title: __('Jsy1'), sortable: true, operate: false },
                        { field: 'jsy2', title: __('Jsy2'), sortable: true, operate: false },




                    ]]
            });
            // Controller.api.bindevent();
            // 为表格绑定事件
            Table.api.bindevent(table);
        },

        api: {
            bindevent: function () {

                //用车单位被选中触发(值被改变)，读取选中数据id
                var cd_id;//储存车队临时变量
                $('#c-cd').data('eSelect', function (data) {
                    // console.log('22',data);
                    cd_id = data['id'];

                });
                $('#c-cp').data('params', function (data) {
                    // console.log(data);
                    return { custom: { id: cd_id } };
                })
                //用车单位被选中触发(值被改变)，读取选中数据，填充联系人
                $('#c-kh').data('eSelect', function (data) {
                    //输出当前选中行的json数据

                    // console.log(data);
                    Fast.api.ajax({
                        url: 'tvsd/kh/lxr',
                        data: { id: data['id'] }
                    }, function (data, ret) {
                        // console.log(data);
                        if (ret.msg == 'ok') {
                            // console.log(data.lxr);
                            $("#c-lxr").val(data.lxr);
                            $("#c-dh").val(data.dh);
                            return false;
                        } else {
                            // console.log("2222");
                            return false;
                        }
                        // return false;
                    }, function (ret) { //error
                        // console.log(ret);
                        // console.log("333");
                        return false;
                    });
                });

                // //所属车队被选中触发(值被改变)，读取选中数据，填充联系人
                // $('#c-cd').data('eSelect', function (data) {
                //     //输出当前选中行的json数据
                //     // console.log(data);
                //     Fast.api.ajax({
                //         url: 'tvsd/cl/cp',
                //         data: { id: data['id'] }
                //     }, function (data, ret) {
                //         // console.log(data);
                //         if (ret.msg == 'ok') {
                //             // console.log(data.lxr);
                //             $('#c-cp').selectPageData(data);
                //             return false;
                //         } else {
                //             // console.log("2222");
                //             return false;
                //         }
                //         // return false;
                //     }, function (ret) { //error
                //         // console.log(ret);
                //         // console.log("333");
                //         return false;
                //     });
                // });
                //车牌号被选中触发(值被改变)，读取选中数据，填充座位数
                $('#c-cp').data('eSelect', function (data) {
                    $('#c-zws').val(data['zws']);
                });
                // //开始日期变化，改变结束日期
                // $("#c-kstime").on('dp.change', function () {
                //     $('#c-jstime').val($('#c-kstime').val());
                // });

                //结束日期值更改触发，判断结束时间不能小于打印开始时间
                $("#c-jstime").on('dp.change', function () {
                    // console.log("1111")
                    if ($('#c-jstime').val() < $('#c-kstime').val()) {
                        //如果结束日期小于开始日期
                        // Toastr.error('结束日期不可小于开始日期')
                        layer.open({
                            content: '结束日期不可小于开始日期',
                            scrollbar: false
                        });
                        $('#c-jstime').val($('#c-kstime').val());
                       
                    }
                });
            

                //驾驶员1被选中触发，读取选中数据，返回填充电话
                $("#c-jsy1").data('eSelect', function (data) {
                    Fast.api.ajax({
                        url: 'tvsd/jsy/jsy',
                        data: { id: data['id'] }
                    }, function (data, ret) {
                        // console.log(data);
                        if (ret.msg == 'ok') {
                            $("#c-jsydh1").val(data.dh);//返回数据填充座位数
                            return false;
                        } else {
                            return false;
                        }
                    }, function (ret) { //error
                        return false;
                    });
                });
                //驾驶员1被选中触发，读取选中数据，返回填充电话
                $("#c-jsy2").data('eSelect', function (data) {
                    Fast.api.ajax({
                        url: 'tvsd/jsy/jsy',
                        data: { id: data['id'] }
                    }, function (data, ret) {
                        // console.log(data);
                        if (ret.msg == 'ok') {
                            $("#c-jsydh2").val(data.dh);//返回数据填充座位数
                            return false;
                        } else {
                            return false;
                        }
                    }, function (ret) { //error
                        return false;
                    });
                });

                Form.api.bindevent($("form[role=form]"));
            },
            queryString: function () {
                return location.search.replace("dialog=1", "").split('&').filter(function (item) {
                    return !!item;
                }).join("&");
            }
        }
    };
    Controller._queryString = Controller.api.queryString();
    return Controller;
});

function setTimeDateFmt(s) {  // 个位数补齐十位数
    return s < 10 ? '0' + s : s;
}
//基于年月日时分秒+随机数生成订单编号
function createordernum() {
    const now = new Date()
    let month = now.getMonth() + 1
    let day = now.getDate()
    let hour = now.getHours()
    let minutes = now.getMinutes()
    let seconds = now.getSeconds()
    month = setTimeDateFmt(month)
    day = setTimeDateFmt(day)
    hour = setTimeDateFmt(hour)
    minutes = setTimeDateFmt(minutes)
    seconds = setTimeDateFmt(seconds)
    let orderCode = now.getFullYear().toString() + month.toString() + day + hour + minutes + seconds + (Math.round(setTimeDateFmt(Math.random()) * 1000000)).toString();
    return orderCode;
    //基于年月日时分秒+随机数生成订单编号
}
//获取url中的参数
function getUrlParam(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)"); //构造一个含有目标参数的正则表达式对象
    var r = window.location.search.substr(1).match(reg);  //匹配目标参数
    if (r != null) return unescape(r[2]); return null; //返回参数值
}